<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='txgl' /></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
</head>
<body>

<div class="layui-fluid">

    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <form name="totalForm" id="totalForm" action="${web_domain}/supplier/withdraw/list" method="get">

                    <div class="layui-inline">
                        <label class="layui-form-label"><fmt:message key='shijian' /></label>
                        <div class="layui-input-inline" style="width:250px;">
                            <input type="text" id="feijin-begin-time" style="width:100px;" name="beginTime" placeholder="<fmt:message key='qrskssj' />" value="<c:if test='${params.beginTime !=null}'>${params.beginTime}</c:if>" autocomplete="off" class="layui-input"> -
                            <input type="text" id="feijin-end-time" style="width:100px;" name="endTime" placeholder="<fmt:message key='qsrjssj' />" value="<c:if test='${params.endTime !=null}'>${params.endTime}</c:if>" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label"><fmt:message key='zt' /></label>
                        <div class="layui-input-inline">
                            <select name="status">
                                <option value="0" <c:if test="${params.status eq 0}">selected="selected"</c:if>><fmt:message key='qxz' /></option>
                                <option value="1" <c:if test="${params.status eq 1}">selected="selected" </c:if>><fmt:message key='dshenh' /></option>
                                <option value="2" <c:if test="${params.status eq 2}">selected="selected"</c:if>><fmt:message key='shtg' /></option>
                                <option value="3" <c:if test="${params.status eq 3}">selected="selected"</c:if>><fmt:message key='shbtg' /></option>
                                <option value="4" <c:if test="${params.status eq 4}">selected="selected"</c:if>><fmt:message key='yff' /></option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> <fmt:message key='ss' /></button>
                    </div>

                </form>
            </div>
        </div>
    </div>

    <div class="layui-card">

        <div class="layui-field-box layui-form">
            <table class="layui-table" lay-size="sm">
                <thead>
                <th><fmt:message key='xh' /></th>
                <th><fmt:message key='sqje' /></th>
                <th><fmt:message key='sqshijian' /></th>
                <th><fmt:message key='jssj' /></th>
                <th><fmt:message key='fp' /></th>
                <th><fmt:message key='jszt' /></th>
                <th><fmt:message key='ptbz' /></th>
                <th><fmt:message key='cz' /></th>
                </thead>

                <c:forEach items="${page.result}" var="item" varStatus="status">
                    <tr>
                        <td>${status.index + 1}</td>
                        <td><fmt:formatNumber value="${item.amount}" type="CURRENCY"/></td>
                        <td><fmt:formatDate value="${item.applyTime}" type="both"/></td>
                        <td><fmt:formatDate value="${item.finalTime}" type="both"/></td>
                        <td>
                            <c:if test="${not empty item.invoice}">
                                <c:forEach items="${fn:split(item.invoice, ';')}" var="image">
                                    <img src="${store_domain}/uploads/${image}" class="preview" style="width:40px;height:40px;"/>
                                </c:forEach>
                            </c:if>
                        </td>
                        <td>
                            <c:choose>
                                <c:when test="${item.status eq 1}"><b style="color:blue"><fmt:message key='ptshz' /></b></c:when>
                                <c:when test="${item.status eq 2}"><b style="color:orange"><fmt:message key='shtgdsjscfp' /></b></c:when>
                                <c:when test="${item.status eq 3}"><b style="color:red"><fmt:message key='shbtg' /></b></c:when>
                                <c:when test="${item.status eq 4}"><b style="color:blue"><fmt:message key='fpyscdptjs' /></b></c:when>
                                <c:when test="${item.status eq 5}"><b style="color:blue"><fmt:message key='yjs' /></b></c:when>
                            </c:choose>
                        </td>
                        <td>${item.note}</td>
                        <td>
                            <div class="layui-btn-container">
                                <c:choose>
                                    <c:when test="${item.status eq 2}"><a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs feijin-update-invoice"><fmt:message key='qscfpzp' /></a></c:when>
                                </c:choose>
                            </div>
                        </td>
                    </tr>
                </c:forEach>
            </table>
            <jsp:include page="/commons/page.jsp" flush="true"/>
        </div>
    </div>

</div>

<script>

    layui.use(['layer', 'form', 'laydate'], function () {
        var layer = layui.layer;
        var laydate = layui.laydate;

        laydate.render({
            elem: '#feijin-begin-time'
        });

        laydate.render({
            elem: '#feijin-end-time'
        });

        //查看详情
        $(".feijin-detail").click(function () {

            var id = $(this).attr("data-id");

            layer.open({
                type: 2
                , title: '<fmt:message key='ckjsdmx' />'
                , content: '${web_domain}/supplier/withdraw/' + id + '/detail'
                , maxmin: true
                , area: ['97%', '97%']
                , btn: ['<fmt:message key='fh' />']
            });
        });

        //补充发票材料
        $(".feijin-update-invoice").click(function () {

            var id = $(this).attr("data-id");

            layer.open({
                type: 2
                , title: '<fmt:message key='qscjsjedepf' />'
                , content: "${web_domain }/supplier/withdraw/invoice?id=" + id
                , maxmin: true
                , area: ['80%', '80%']
                , btn: ['<fmt:message key='qd' />', '<fmt:message key='qx' />']
                , yes: function (index, layero) {
                    var submit = layero.find('iframe').contents().find("#submit");
                    submit.click();

                }
            });
        });


    });

</script>
</body>
</fmt:bundle>
</html>
